package com.zx.mes.demo.hyl.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * sentinel controller
 * https://github.com/spring-cloud-incubator/spring-cloud-alibaba/wiki/Sentinel
 *
 * @author 华云龙
 * @date 2019-2-19
 */
@RestController
@RefreshScope
public class SentinelController {

    @Value("${current.env:pro}")
    private String env;

    @Value("${server.port}")
    private String port;

    @GetMapping(value = "/hello")
    @SentinelResource("hello")
    public String hello() {
        System.out.println("端口号:"+port+" 环境:"+env);
        return "Hello Sentinel 环境:"+env;
    }
}
